﻿#ifndef _blua_h_
#define _blua_h_

#include "blua_def.h"

bb_c blua_lib_func pblua_t bl_allocstate_ex( blua_alloc pfn_alloc, void* p_param );
bb_c blua_lib_func pblua_t bl_allocstate( void* p_param );
bb_c blua_lib_func int bl_freestate( pblua_t p_lua );
bb_c blua_lib_func pblua_t bl_getblua( lua_State* p_state );

bb_c blua_lib_func int bl_loadfile( pblua_t p_lua, const char* psz_file );
bb_c blua_lib_func int bl_loadstring( pblua_t p_lua, const char* psz_str );
bb_c blua_lib_func int bl_dofile( pblua_t p_lua, const char* psz_file );
bb_c blua_lib_func int bl_dostring( pblua_t p_lua, const char* psz_str );
bb_c blua_lib_func int bl_checkstack( pblua_t p_lua, int n_extra );
bb_c blua_lib_func int bl_call( pblua_t p_lua, int n_arg, int n_result );

bb_c blua_lib_func int bl_insert( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_pop( pblua_t p_lua, int n_cnt );
bb_c blua_lib_func int bl_pushnil( pblua_t p_lua );
bb_c blua_lib_func int bl_pushint( pblua_t p_lua, int n_value );
bb_c blua_lib_func int bl_pushstring( pblua_t p_lua, const char* psz_value );
bb_c blua_lib_func int bl_pushlightpointer( pblua_t p_lua, void* p_pointer );
bb_c blua_lib_func int bl_pushfunction( pblua_t p_lua, lua_cfunc pfn_func );
bb_c blua_lib_func int bl_pushcclosure( pblua_t p_lua, lua_cfunc pfn_func, int n_upvcnt );
bb_c blua_lib_func int bl_pushtable( pblua_t p_lua );
bb_c blua_lib_func int bl_pushvalue( pblua_t p_lua, int n_index );

bb_c blua_lib_func int bl_isnumber( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_isstring( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_isboolean( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_isfunction( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_iscfunction( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_islightuserdata( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_isuserdata( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_istable( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_isthread( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_isnil( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_isnone( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_isnoneornil( pblua_t p_lua, int n_index );

bb_c blua_lib_func int bl_toint( pblua_t p_lua, int n_index, int* pn_value );
bb_c blua_lib_func int bl_tostr( pblua_t p_lua, int n_index, char* psz_buffer, size_t* pun_len );
bb_c blua_lib_func int bl_tobool( pblua_t p_lua, int n_index, int* pn_value );
bb_c blua_lib_func int bl_tocfunc( pblua_t p_lua, int n_index, lua_cfunc* ppfn_value );
bb_c blua_lib_func int bl_topointer( pblua_t p_lua, int n_index, blua_pointer* pbp_value );
bb_c blua_lib_func int bl_tonumber( pblua_t p_lua, int n_index, blua_number* pd_value );
bb_c blua_lib_func int bl_touserdata( pblua_t p_lua, int n_index, void** pp_value );

bb_c blua_lib_func int bl_gettable( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_settable( pblua_t p_lua, int n_index );
bb_c blua_lib_func int bl_enumtable( pblua_t p_lua, int n_index, blua_cfunc pfn_onenum );

bb_c blua_lib_func int bl_backupstack( pblua_t p_lua, int* pn_top );
bb_c blua_lib_func int bl_recoverystack( pblua_t p_lua, int n_top );
bb_c blua_lib_func int bl_getfieldbyname( pblua_t p_lua, const char* pszu8_fieldname );
bb_c blua_lib_func int bl_getintbyname( pblua_t p_lua, const char* pszu8_fieldname, int* pn_value );
bb_c blua_lib_func int bl_getstringbyname( pblua_t p_lua, const char* pszu8_fieldname, char* psz_buffer, size_t* pun_len );

bb_c blua_lib_func int bl_setfieldbyname( pblua_t p_lua, const char* pszu8_fieldname, int* pn_tableindex );
bb_c blua_lib_func int bl_setintbyname( pblua_t p_lua, const char* pszu8_fieldname, int n_value );
bb_c blua_lib_func int bl_setstringbyname( pblua_t p_lua, const char* pszu8_fieldname, const char* psz_buffer );
bb_c blua_lib_func int bl_setcclosurebyname( pblua_t p_lua, const char* pszu8_fieldname, lua_cfunc pfn_func, int n_upvcnt );
bb_c blua_lib_func int bl_setfuncbyname( pblua_t p_lua, const char* pszu8_fieldname, lua_cfunc pfn_func );
bb_c blua_lib_func int bl_setbcclosurebyname( pblua_t p_lua, const char* pszu8_fieldname, blua_cfunc pfn_bfunc, int n_upvcnt );
bb_c blua_lib_func int bl_setbfuncbyname( pblua_t p_lua, const char* pszu8_fieldname, blua_cfunc pfn_bfunc );

bb_c blua_lib_func int bl_exportlib( pblua_t p_lua, const char* pszu8_tablename, pluareg_t p_regs, int n_upvcnt );
bb_c blua_lib_func int bl_exportblib( pblua_t p_lua, const char* pszu8_tablename, pbluareg_t p_regs, int n_upvcnt );

bb_c blua_lib_func int bl_dumpstack( FILE* p_file, pblua_t p_lua );
bb_c blua_lib_func int bl_dump( FILE* p_file, pblua_t p_lua );

#endif
/***********************************

2010/11/23-xx:xx @ corp.king
blua.h
bey0ndc00de
utf-8 --with-sig

************************************/
/*last for linux*/
